package com.archgeek.rpc.thrfit;

import com.archgeek.rpc.thrfit.gen.StudentService;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

/**
 * @author pizhihui
 * @date 2022-04-06 21:03
 */
public class ThriftClient {

    public static void main(String[] args) {

        Runnable r = ThriftClient::singlePeopleAccess;
        TlUtil.timeTasks(10, 2, r);

    }


    public static void singlePeopleAccess() {
        try {
            TTransport transport = new TSocket("127.0.0.1", 8732);

            TBinaryProtocol protocol = new TBinaryProtocol(transport);
            StudentService.Client client = new StudentService.Client(protocol);

            transport.open();

            int i = 5;
            while (i > 0) {

                String res = client.sayHello(i + "");
                System.out.println(res);
                i--;
            }
            transport.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
